package workcount;

/**
 * word 单词实体，实现Comparable，可以排序
 *
 * */
public class Word implements Comparable<Word>{
    private String text; //单词文本
    private int times;   //单词次数

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public int getTimes() {
        return times;
    }

    public void setTimes(int times) {
        this.times = times;
    }

    public Word(String word, int i) {
        this.text = word;
        this.times=i;
    }

    @Override
    public int compareTo(Word a) {
        return (-1)*(this.getTimes()-a.getTimes());
    }
}
